Python How do I get multiple results in the same excel sheet

您所在的位置:网站首页 python pandas agg Python How do I get multiple results in the same excel sheet

Python How do I get multiple results in the same excel sheet

#Python How do I get multiple results in the same excel sheet | 来源: 网络整理| 查看: 265

I now use the groupby() function to get the averages of the first 6 columns in a data collection that has 10 columns, as well as the minimum and maximum values for the remaining 4 columns. The problem is that I keep receiving problems saying that the "list" object has no property "to excel" when I try to input the results into a new excel sheet.

avg = df.groupby('column1')[['column2' , 'column3', 'column4' ,'column5', 'column6', 'column7' ]].mean() c8= (df.assign(c8=df['column8'].abs()) .groupby(['column1'])['column8'].agg([('min' , 'min'), ('max', 'max')]) .add_prefix('c8')) c9= (df.assign(c9=df['column9'].abs()) .groupby(['column1'])['column9'].agg([('min' , 'min'), ('max', 'max')]) .add_prefix('c9')) c10= (df.assign(c10=df['column'].abs()) .groupby(['column1'])['column10'].agg([('min' , 'min'), ('max', 'max')]) .add_prefix('c10')) df = [avg , c8, c9, c10] #print(df) wb = pd.ExcelWriter('C:filepath.xlsx' , engine='xlsxwriter') df.to_excel(wb,sheet_name='Results') wb.save()

Whenever I run any of the functions by themselves, they all work fine, the issue is when I put them together.

What I am expecting is an excel sheet filled with the corresponding data presented like this:

column1 column2 column3 column4 column5 column6 column7 c8min c8max c9min c9max c10min c10max


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3